import React, { Component } from 'react'
export default class reducer01 extends Component {
    state = { num:0    }
    add = (params) => {
        const { num } = this.state;
        num +=1;
        this.setState({num})
    }
    sup = (params) => {
        let { num } = this.state;
        num -=1;
        this.setState({num})
    }    
    render() {
        const { num } = this.state
        return (
            <div>
                {num} <br />
                <button onClick={this.add}>相加1</button>
                <button onClick={this.sup}>相减1</button>
            </div>
        )
    }
}
